package cn.wolfcode.shop.cloud.common;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class CommonControllerAdvice {

    //捕获自定义异常
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Result handlerBusiness(BusinessException e){
        e.printStackTrace();
        return Result.error(e.getCodeMsg());
    }

    //捕获系统异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handlerException(Exception e){
        e.printStackTrace();
        return Result.defaultError();
    }
}
